package vip.george.p0860;

public class P860 {


    public boolean lemonadeChange(int[] bills) {
        // 记录零钱的数量（因为最大的面额是20，20的不能当做零钱）
        int five = 0;
        int ten = 0;
        for (int bill : bills) {
            switch (bill) {
                case 5:
                    five++;
                    break;
                case 10:
                    five--;
                    ten++;
                    break;
                case 20:
                    if (ten > 0) {
                        ten--;
                        five--;
                    } else {
                        five -= 3;
                    }
                    break;
            }
            // 只要面额为5的数量小于0，则返回false
            if (five < 0) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        P860 p860 = new P860();
        System.out.println(p860.lemonadeChange(new int[] {5,5,5,10,20}));
        System.out.println(p860.lemonadeChange(new int[] {5,5,10}));
        System.out.println(p860.lemonadeChange(new int[] {10,10}));
    }
}
